package DBComm;
//Hold Stats regarding IMing activity
//
//Scott J. Ditch
public class Stats {

	private int messages;
	private int aveLength;
	private int fileShares;
	private int statusChanges;
	private int users;
	private int buddies;
	
	private int currentMessages;
	private long startTime;
	
	
	public Stats()
	{
		System.out.println("Building Stats");
		startTime = System.currentTimeMillis();
	}
	
	public void addMessage(int length)
	{   
		messages++;
		currentMessages++;
		aveLength = ((messages * aveLength) + length)/ messages;
	}
	
	public void fileShared()
	{
		fileShares++;
	}
	
	public void changedStatus()
	{
		statusChanges++;
	}
	
	public void adduser()
	{
		users++;
	}
	
	public void moreBuddies()
	{
		buddies++;
	}
	
	public void removedBuddy()
	{
		buddies--;
	}
	
	//Give the time the program has been running in milliseconds.
	private long getTimeRunning()
	{
		return ((System.currentTimeMillis()) - startTime);
	}
	
	
//	//RETURN METHODS
//	//
//	public int getMessgaes()
//	{
//		return messages;
//	}
//	
//	public int getAverageLength()
//	{
//		return aveLength;
//	}
//	
//	public int getFilesShared()
//	{
//		return fileShares;
//	}
//	
//	public int getStatusChanges()
//	{
//		return statusChanges;
//	}
	
	public void printStats()
	{
		System.out.println("\n Stats: \n");
		System.out.println(" The amount of messages sent: " + messages);
		System.out.println(" The average length of messages sent: " + aveLength);
		System.out.println(" The amount of files shared: " + fileShares);
		System.out.println(" The amount of status changes: " + statusChanges);
		System.out.println(" New users this session: " + users);
		System.out.println(" Buddies linked session: " + buddies);
		System.out.println(" Time the DBComm has been running (Milliseconds): " + getTimeRunning());
	}
	
}
